<?php $user=$session->read('User');?>
<div class="right_side_operate_area">
	<div class="right_side_title left">
		<h2>
		<?php 
		$projectname=$form->value("Project.project_name");
		echo $html->link($projectname,"/projects/showinfo/".$id);
		?>
		</h2>
		<div class="clear"></div>
	</div>
    <div class="right item_add_btn">
    <?php 
    		$str_title=__("Add",true);
    		if($id){
    			$str_title=__("Edit",true);
    		}
    		echo $html->link(__("Cancel",true).$str_title,"/projects/index/",array("onclick"=>"history.go(-1);return false;"));
    ?>
    </div>
    <div class="clear"></div>
</div>
<div class="right_side_scollbar">
    <div class="detail_info_panel">
    	<?php echo $form -> create('projects', array('url' => '/projects/editinfo/'.$id,'enctype'=>'multipart/form-data','type'=> 'post','onsubmit'=>'return checksave()') ); ?>
		<div class="details_item_line">
            <div class="details_item">
                <div class="form_left_title left"><?php __("Project Name")?>：</div>
                <div class="form_right_e_input left"><?php echo $form->text('Project.project_name',array('style'=>'width:250px',"maxlength"=>"100"));?></div>
                <div id='projectnamemessage' style='display:none;' class="error_message">请输入项目名称</div>
                <div id='pname' style='display:none;'><?php echo $form->value('Project.project_name')?></div>
            </div>
        </div>
        <div class="details_item_line">
             <div class="details_item">
                <div class="form_left_title left"><?php __("Company Name")?>：</div>
                <div class="form_right_e_input left"><?php echo $form->text('Project.company_name',array('style'=>'width:250px',"maxlength"=>"100"));?></div>
           		<div id='projectcnamemessage' style='display:none;' class="error_message">企业名称已存在</div>
           		<div id='cname' style='display:none;'><?php echo $form->value('Project.company_name')?></div>
            </div>
        </div>
        <div class="details_item_line">
            <div class="details_item">
                <div class="form_left_title left"><?php __("Industry")?>：</div>
                <div class="form_right_add left">
                	<?php 
		            $industryidlist="";
		            if($pros_cvalues){
			            foreach($pros_cvalues as $pros_cvalue){
			            	if(!empty($pros_cvalue["cvid"])){
			            		$industryidlist.=$pros_cvalue["cvid"].',';
			            	}
			            }
		            }
		            ?>
		            <div id="pcvalueidlist" class="txthide"><?php echo $industryidlist?></div>
                	<div id="taglist" class="added_item_list left"></div>
                    <div class="add_item_btn left">
	                    <a id="add_drop_float_click" href="javascript:void(0)"><?php __("Add")?></a>
		                <div id="add_float_box" class="add_float_box" style="display:none;">
		                    <ul>
			                    <?php 
			                    $dan="'";
			                    foreach($industrys as $key=>$industry){
									echo "<li><label>";
									echo '<input type="checkbox" id="chbox'.$key.'" onclick="settxt(this,'.$dan.$industry.$dan.','.$dan."#ProjectIndustryname".$dan.','.$dan."#ProjectIndustryid".$dan.','.$dan."#taglist".$dan.','.$dan."add_drop_float_click".$dan.')" value="'.$key.'" />'.$industry;
									echo "</label></li>";
									echo "<span id='span".$key."' class='txthide'>".$industry."</span>";
								}?> 
							</ul>
		                </div>
					</div>
                    <?php echo $form->text('Project.industryname',array('class'=>'txthide','readonly'=>'true','style'=>'width:500px'));?>
                    
		            <?php echo $form->text('Project.industryid',array('class'=>'txthide'));?>
                </div>
            </div>
        </div>
        
        <!-- 信息来源 开始 -->
        <div class="details_item_line">
            <div class="details_item">
            	 <div class="form_left_title left">信息来源：</div>
            	 <div class="form_right_add left">
                	<?php 
		            $informationlist="";
		            if($informationfroms){
			            foreach($informationfroms as $informationfrom){
			            	if(!empty($informationfrom["cvid"])){
			            		$informationlist.=$informationfrom["cvid"].',';
			            	}
			            }
		            }
		            ?>
		            <div id="informationfromidlist" class="txthide"><?php echo $informationlist?></div>
                	<div id="taglistct" class="added_item_list left"></div>
                    <div class="add_item_btn left">
	                    <a id="add_drop_float_clickct" href="javascript:void(0)"><?php __("Add")?></a>
		                <div id="add_float_boxct" class="add_float_box" style="display:none;">
		                    <ul>
			                    <?php 
			                    $dan="'";
			                    foreach($informations as $key=>$information){
									echo "<li><label>";
									echo '<input type="checkbox" id="chbox'.$key.'" onclick="settxt(this,'.$dan.$information.$dan.','.$dan."#ProjectInformationfromname".$dan.','.$dan."#ProjectInformationfromid".$dan.','.$dan."#taglistct".$dan.','.$dan."add_drop_float_clickct".$dan.')" value="'.$key.'" />'.$information;
									echo "</label></li>";
									echo "<span id='span".$key."' class='txthide'>".$information."</span>";
								}?> 
							</ul>
		                </div>
					</div>
                    <?php echo $form->text('Project.informationfromname',array('class'=>'txthide','readonly'=>'true','style'=>'width:500px'));?>
		            <?php echo $form->text('Project.informationfromid',array('class'=>'txthide'));?>
                </div>
            </div>
        </div>
        
        <!-- 信息来源 结束-->
        
        <div class="details_item_line">
            <div class="details_item">
                <div class="form_left_title left"><?php __("Contact")?>：</div>
                <div class="form_right_e_input left"><?php echo $form->text('Project.contact',array("maxlength"=>"20"));?></div>
            </div>
            <div class="details_item">
                <div class="form_left_title left"><?php __("Tel")?>：</div>
                <div class="form_right_e_input left"><?php echo $form->text('Project.tel',array("maxlength"=>"20"));?></div>
            </div>
            <div class="details_item">
                <div class="form_left_title left"><?php __("Mail")?>：</div>
                <div class="form_right_e_input left"><?php echo $form->text('Project.email',array("maxlength"=>"50","style"=>"ime-mode:disabled"));?></div>
                <?php echo $form->text('User.uemail',array("class"=>"txthide","value"=>$form->value('Project.email')));?>
                <div id='projectemailmessage' style='display:none;' class="error_message">邮箱格式不正确</div>
            </div>
        </div>
        <div class="details_item_line">
            <div class="details_item">
                <div class="form_left_title left">性别：</div>
                <div class="form_right_e_input left">
                <?php
                 $attributes=array('legend'=>false);
                 echo $form->radio('Project.sex',array("0"=>"男","1"=>"女"),$attributes);
                 ?>
                </div>
            </div>
            <div class="details_item">
                <div class="form_left_title left">毕业院校：</div>
                <div class="form_right_e_input left"><?php echo $form->text('Project.graduate_school',array("maxlength"=>"20"));?></div>
            </div>
            <div class="details_item">
                <div class="form_left_title left">学历学位：</div>
                <div class="form_right_e_input left"><?php echo $form->select('Project.education',$educations, null,null,null);?></div>
            </div>
        </div> 
    <div class="details_item_line">
            <div class="details_item">
                <div class="form_left_title left">出生年月：</div>
                <div class="form_right_e_input form_date_picker left"><?php echo $form->text('Project.birthday',array("maxlength"=>"10","onfocus"=>"WdatePicker()","style"=>"width:130px"));?></div>
            </div>
            <div class="details_item">
                <div class="form_left_title left">国籍：</div>
                <div class="form_right_e_input left"><?php echo $form->text('Project.nation',array("maxlength"=>"20"));?></div>
            </div>
        </div>  
        <div class="details_item_line">
            <div class="details_item">
                <div class="form_left_title left"><?php __("Regedit Time")?>：</div>
                <div class="form_right_e_input form_date_picker left"><?php echo $form->text('Project.reg_time',array("maxlength"=>"10","onfocus"=>"WdatePicker()","style"=>"width:130px"));?></div>
            </div>
            <div class="details_item">
                <div class="form_left_title left"><?php __("Regedit Capital")?>：</div>
                <div class="form_right_e_input left">
                <?php echo $form->text('Project.capital',array("placeholder"=>"0.00","onkeydown"=>"checkpricekeyup(this,event)","style"=>"width:70px","maxlength"=>"10"));?>
                  <?php
                  $attributes=array('legend'=>false);
                   echo $form->radio('Project.cap_type',array("0"=>"万元","1"=>"万美元"),$attributes);?>
                </div>
            </div>
        </div>
        <?php 
        	$id=$form->value('Project.id');
            if(!empty($id)){
        ?>
        <div class="details_item_line">
        	<div class="details_item">
	        	<div class="form_left_title left"><?php __("In Phase")?>：</div>
	            <div class="form_right_e_input left">
	            <?php 
		            $selectphase=$form->value("Project.phase");
		            echo $form->select('Project.phase',$phases,$selectphase,array("onchange"=>"selectregdecl(this)"),null);
		            echo $form->text('Project.txtphase',array('class'=>'txthide'));
	            ?>
	            <?php 
	            	$selectregtype=$form->value("Project.reg_type");
		            echo $form->select('Project.reg_type',$reg_type,$selectregtype,
		            array("onchange"=>"selectregtypedecl(this)","id"=>"reg_type","class"=>"txthide"),null);
		            echo $form->text('Project.txtreg_type',array('class'=>'txthide'));
		        ?>
		        <?php $select_phase=$form->value("Project.reg_decl_phase"); ?>
		        
	            <?php echo $form->select('Project.nreg_phase',$nreg_phase,$select_phase,
	            array("id"=>"nreg_phase","class"=>"txthide","onchange"=>"addexamineremark(this)"),null);?>
	            
	        	<?php echo $form->select('Project.wreg_phase',$wreg_phase,$select_phase,
	        	array("id"=>"wreg_phase","class"=>"txthide","onchange"=>"addexamineremark(this)"),null);?>
	        	
	        	<?php echo $form->select('Project.decl_phase',$decl_phase,$select_phase,
	        	array("id"=>"decl_phase","class"=>"txthide","onchange"=>"addexamineremark(this)"),null);?>
	        	</div>
            </div>
        </div>
        <div class="details_item_line">
        	<div class="details_item" id="examineremark" style="display:none">
	        	<div class="form_left_title left">前置审批备注：</div>
	        	<div class="form_right_e_input left">
	        		<?php echo $form->textarea('Project.remark',array('style'=>'width:200px;height:50px'));?>
	        	</div>
	        </div>
        </div>
        <?php }?>
        <div class="details_item_line edit_form_btn">
            <div class="details_item">
            	<div class="form_left_title left"></div>
                <div class="form_add_submit left">
	                <?php echo $form->submit(__('Save',true), array("div"=>false)) ?>
	                <?php  echo $form->hidden('Project.id'); ?>
	                <?php  echo $form->hidden('Project.isfile'); ?>
                </div>
                <?php if(empty($id)){?>
                <div class="form_add_attache_submit left">
	                <?php echo $form->submit('保存并添加附件', array("div"=>false,"onclick"=>"savefile()")) ?>
                </div>
                <?php }?>
            </div>
        </div>
        </form>
    </div>
</div>

<?php echo $this->element('constant') ?>
<?php echo $javascript->link('project.js');?>
<script type="text/javascript">
	var webpath=$("#getpath").attr('href');
	function savefile() {
		$("#ProjectIsfile").val("1");
		return checksave();
	}
	function addEV(C,B,A){
		if(window.attachEvent){
			C.attachEvent("on"+B,A);
		}else{
			if(window.addEventListener){
				C.addEventListener(B,A,false);
			}
		}
	}
	addEV(document,"click",function(E){
		var E=E||window.event;
		var A=E.target||E.srcElement;
		var D=window.event?E.button:E.which;
		var C=G("add_drop_float_click"),B=G("add_float_box");
		while(A&&A!=document.body&&A.tagName.toLowerCase()!="html"){
			if(A==C){break}
			if(A==B){break}
			A=A.parentNode
		}
		if(A==B){
			if(B!=null){
				B.style.display="block";
			}
		}else if(A!=C){
			if(B!=null){
				B.style.display="none";
			}
		}else{
			if(D<2){
				B.style.display=B.style.display=="block"?"none":"block";
			}
		}
	});

	function addEVct(C,B,A){
		if(window.attachEvent){
			C.attachEvent("on"+B,A);
		}else{
			if(window.addEventListener){
				C.addEventListener(B,A,false);
			}
		}
	}
	addEVct(document,"click",function(E){
		var E=E||window.event;
		var A=E.target||E.srcElement;
		var D=window.event?E.button:E.which;
		var C=G("add_drop_float_clickct"),B=G("add_float_boxct");
		while(A&&A!=document.body&&A.tagName.toLowerCase()!="html"){
			if(A==C){break}
			if(A==B){break}
			A=A.parentNode
		}
		if(A==B){
			if(B!=null){
				B.style.display="block";
			}
		}else if(A!=C){
			if(B!=null){
				B.style.display="none";
			}
		}else{
			if(D<2){
				B.style.display=B.style.display=="block"?"none":"block";
			}
		}
	});
	
	
	$(document).ready(function() {
		$("#ProjectProjectName").keyup(function() {    		
			var pname=this.value;
			if(pname.trim()!=""){
	   			var pnames=$("#pname").html();
	   			if(pnames!=pname){
		   			var urlpath=webpath+'projects/checkpname/'+encodeURIComponent(pname);
					$.ajax({     	   
				        url: urlpath, 
				        success:function(data){
				        	if(data=="1")
				        	{
				        		$("#projectnamemessage").css('display','block');
				        		$("#projectnamemessage").html('项目名称已存在');
				        	}else{
				        		$("#projectnamemessage").css('display','none');
				        		$("#projectnamemessage").html('请输入项目名称');
				        	}
				        }
				    });
			    }else{
			    	$("#projectnamemessage").css('display','none');
				    $("#projectnamemessage").html('请输入项目名称');
			    }
		    }else{
		    	$("#projectnamemessage").css('display','block');
			    $("#projectnamemessage").html('请输入项目名称');
		    }
	    });

		$("#ProjectCompanyName").keyup(function() {    		
			var cname=this.value;
			if(cname.trim()!=""){
	   			var cnames=$("#cname").html();
	   			if(cnames!=cname){
		   			var urlpath=webpath+'projects/checkcname/'+encodeURIComponent(cname);
					$.ajax({     	   
				        url: urlpath, 
				        success:function(data){
				        	if(data=="1")
				        	{
				        		$("#projectcnamemessage").css('display','block');
				        	}else{
				        		$("#projectcnamemessage").css('display','none');
				        	}
				        }
				    });
			    }else{
			    	$("#projectcnamemessage").css('display','none');
			    }
		    }
	    });
	    
	    $("#ProjectEmail").keyup(function() {  
	     	var mail=this.value;
	     	var umail=$("#UserUemail").val();
		 	checkuserbymail(webpath,mail,umail,"#projectemailmessage");
	    });  	
	    $("#ProjectRegTime").click(function() {  
	     	$("#add_float_box").css('display','none');
	    });
	});
</script>